<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    html,
    body {
      height: 500%;
      user-select: none;
    }

    .dialogMark {
      position: fixed;
      top: 0;
      left: 0;
      z-index: 999;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.3);
    }

    .dialogBox {
      position: fixed;
      z-index: 1000;
      width: 200px;
      height: 300px;
      background-color: #fff;
      overflow: hidden;
    }

    .dialogBox h3.dialogTitle {
      position: relative;
      height: 35px;
      line-height: 35px;
      padding: 0 10px;
      background-color: #ddd;
      border-bottom: 1px solid #aaa;
      cursor: move;
    }

    .dialogBox h3.dialogTitle i {
      position: absolute;
      right: 10px;
      top: 50%;
      transform: translate(0, -50%);
      width: 20px;
      height: 20px;
      text-align: center;
      line-height: 20px;
      font-style: normal;
      font-weight: normal;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      font-size: 16px;
      border-radius: 50%;
      background-color: #aaa;
      color: #fff;
      cursor: pointer;
    }
  </style>
</head>

<body>
  <div class="dialogMark"></div>
  <div class="dialogBox">
    <h3 class="dialogTitle">Hello World<i class="dialogClose">X</i></h3>
    <div class="con">

    </div>
  </div>

  <script src="./Subscribe.js"></script>
  <script src="./drag-plugin-3.js"></script>
  <script>
    window.onload = function () {
      let el = document.querySelector('.dialogBox')
      // 屏幕高度宽度
      const winW = document.documentElement.clientWidth;
      const winH = document.documentElement.clientHeight;
      // 盒子的高度宽度
      const boxW = el.offsetWidth;
      const boxH = el.offsetHeight;

      // 居中
      el.style.top = (winH - boxH) / 2 + 'px';
      el.style.left = (winW - boxW) / 2 + 'px';

      window.onresize = function () {
        // 屏幕高度宽度
        let resozeWinW = document.documentElement.clientWidth;
        let resozeWinH = document.documentElement.clientHeight;
        // 设置盒子居中
        el.style.top = (resozeWinH - boxH) / 2 + 'px';
        el.style.left = (resozeWinW - boxW) / 2 + 'px';
      }
      const drag = new Drag(el, {
        selector: 'h3'
      });
      drag.subDown.add(function () {
        console.log('鼠标按下过程中做点事-one')
      })
      drag.subDown.add(function () {
        console.log('鼠标按下过程中做点事-two')
      })

      drag.subMove.add(function () {
        console.log('鼠标移动过程中做点事-one')
      })
      drag.subMove.add(function () {
        console.log('鼠标移动过程中做点事-two')
      })
      drag.subUp.add(function () {
        console.log('鼠标抬起过程中做点事-one')
      })
      drag.subUp.add(function () {
        console.log('鼠标抬起过程中做点事-two')
      })

    }
  </script>
</body>

</html>